<template>
    <div style="height: 100%">
      <div class="main-tab">
        <x-header id="header" slot="header" :left-options="{showBack: false}" >
          <x-icon type="ios-arrow-back" slot="left" style="fill:#fff;" @click="back"></x-icon>
          <span slot="default" class="header-tit">商家</span>
        </x-header>
        <div class="main-headerAndTab">
          <tab bar-active-color="#AD2532" :line-width="2" custom-bar-width="1.43rem" active-color="#AD2532" default-color="#9B9B9B" :scroll-threshold="6" class="tab">
            <tab-item selected  active-class="active1" @click.native="change1">全部</tab-item>
            <tab-item active-class="active1" @click.native="change2">烟店</tab-item>
            <tab-item active-class="active1" @click.native="change3">酒店</tab-item>
            <tab-item active-class="active1" @click.native="change4">烟酒店</tab-item>
            <tab-item active-class="active1" @click.native="change5">红酒</tab-item>
            <tab-item active-class="active1" @click.native="change6">啤酒</tab-item>
          </tab>
          <group>
            <cell-box v-for="(item,index) in shoplist" :key="item.id" @click.native="shop(item.id)">
              <div class="shop">
                <div class="shop-left">
                  <img :src="item.shopPicture" class="shop-img">
                  <div class="shop-info">
                    <div class="shop-name">{{item.shopName}}</div>
                    <div class="shop-address">
                      <img src="../../../static/icon/dizhi-2.png" class="address-icon">
                      <div class="address">{{item.shopAddress}}</div>
                    </div>
                  </div>
                </div>
                <div class="shop-right">4.5km</div>
              </div>
            </cell-box>
          </group>
          <div class="more">没有更多了哦～</div>
        </div>
      </div>
    </div>
</template>

<script>
  import { getShopList } from '@/api/shop';

  export default {
        name: "business",
      methods:{
        back(){
          this.$router.go(-1)
        },
        change1(){
          this.shopType='';
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })

        },
        change2(){
          this.shopType=1;
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        },
        change3(){
          this.shopType=2;
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        },
        change4(){
          this.shopType=3;
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        },
        change5(){
          this.shopType=4;
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        },
        change6(){
          this.shopType=5;
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        },
        shop(id){
          this.globalData.shopid=id;
          this.$router.push({
            name:'shop_detail'
          })
        },
        getShopList(){
          getShopList({
            shopType:this.shopType,
            shopName:this.shopName
          }).then(res =>{
            console.log(res)
            this.shoplist=res.data;
          })
        }
      },
      data(){
        return{
          flag1:true,
          flag2:false,
          flag3:false,
          flag4:false,
          flag5:false,
          flag6:false,
          shoplist:[
          ],
          shopType:'',
          shopName:''
        }
      },
    created(){
          this.getShopList();
    }

    }
</script>

<style scoped>
  .header-tit{
    margin-top: 0.2rem;
  }
  #header{
    width: 100%;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
  }
  .active1{
    font-weight: bolder;
  }
  .tab{
    background: #FFFFFF;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.02), 0 2px 4px 0 rgba(173,37,50,0.05);
  }
  .shop{
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  .shop-left{
    display: flex;
    flex-direction: row;
  }
  .shop-img{
    width: 5.71rem;
    height: 5.71rem;
  }
  .shop-info{
    margin-left: 1.01rem;
  }
  .shop-name{
    font-size: 17px;
    color: #4A4A4A;
    letter-spacing: 0;
  }
  .shop-address{
    display: flex;
    flex-direction: row;
    margin-top: 0.72rem;
  }
  .address-icon{
    width: 1.07rem;
    height: 1.07rem;
  }
  .address{
    margin-left: 0.36rem;
    font-size: 14px;
    color: #9B9B9B;
    letter-spacing: 0;
    text-align: justify;
  }
  .shop-right{
    font-size: 12px;
    color: #9B9B9B;
    letter-spacing: 0;
    text-align: justify;
    margin-top: 5.14rem;
  }
  .more{
    position: absolute;
    left: 50%;
    margin-left: -3.43rem;
    margin-top: 1.07rem;
    font-size: 14px;
    color: #9B9B9B;
    letter-spacing: -0.34px;
    text-align: justify;
  }
</style>
